﻿/**
 * 
 * @file FITKAcousticsAbsPhysicsProp.h
 * @brief 物流属性抽象类与管理器声明 
 * @author LiBaojun (libaojunqd@foxmail.com)
 * @date 2024-10-06
 * 
 */
#ifndef _FITK_ACOUSTICS_ABS_PHYSICS_PROP_H___
#define _FITK_ACOUSTICS_ABS_PHYSICS_PROP_H___
 
#include "FITKAcousticsPhysicsAPI.h"
#include "FITK_Kernel/FITKCore/FITKAbstractNDataObject.h"
#include "FITK_Kernel/FITKCore/FITKAbstractDataManager.hpp"
#include "FITK_Kernel/FITKCore/FITKCoreMacros.h"

namespace Acoustics
{
    class FITKAcousticsAbsMaterial;
     /**
      * @brief 物理属性基类，抽象类
      * @author LiBaojun (libaojunqd@foxmail.com)
      * @date 2024-10-06
      */
    class FITKAcousticsPhysicsAPI FITKAcousticsAbsPhysicsProp : 
        public Core::FITKAbstractNDataObject
    {
        Q_OBJECT
    public:
        /**
         * @brief 物理属性类型
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-06
         */
        enum AcousticsPhyscisPropType
        {
            APPNone,                            ///< 无效类型
            APPBeam,                            ///< 梁
            APPUniformPlat,                     ///< 均质板
            APPGeneralLaminatePhysicalProperty, ///< 自由阻尼层合板
            APPRibbedphysicalProperty,          ///< 加筋板
        };

    public:
        /**
         * @brief Construct a new FITKAcousticsAbsPhysicsProp object
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-06
         */
        explicit FITKAcousticsAbsPhysicsProp() = default;
        /**
         * @brief Destroy the FITKAcousticsAbsPhysicsProp object
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-06
         */
        virtual ~FITKAcousticsAbsPhysicsProp() = 0;
        /**
         * @brief 获取物理属性类型
         * @return AcousticsPhyscisPropType 
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-06
         */
        virtual AcousticsPhyscisPropType getPhysicsPropType() = 0;
        /**
         * @brief 设置材料ID
         * @param[i]  id             材料id
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-06
         */
        void setMaterialID(const int id);
        /**
         * @brief 获取材料id
         * @return int 
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-06
         */
        int getMaterialID() const;
        /**
         * @brief 获取材料名称
         * @return QString 
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-06
         */
        QString getMaterialName();
        /**
         * @brief 获取材料对象
         * @return FITKAcousticsAbsMaterial* 
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-06
         */
        FITKAcousticsAbsMaterial* getMaterial();

        template <class T>
        /**
         * @brief 获取材料并强制类型转换为T类型
         * @return T* 
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-06
         */
        T* getMaterialT()
        {
            return dynamic_cast<T*>(this->getMaterial());
        }
        /**
         * @brief 设置描述
         * @param[i] des 描述信息
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-06
         */
        void setDescribe(const QString& des);
        /**
         * @brief 获取描述
         * @return QString
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-06
         */
        QString getDescribe();
        /**
         * @brief 设置颜色，归一化表示
         * @param[i] r,g,b  颜色rgb值，范围是0.0-1.0  
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-06
         */
        void setColor(float r, float g, float b);
        /**
         * @brief 获取颜色，归一化表示
         * @param[o] rgb  颜色rgb值，三个分量，范围是0.0-1.0
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-06
         */
        void getColor(float* rgb);
        /**
         * @brief    更新颜色-颜色改为默认颜色
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-01-20
         */
        virtual void updateDefaultColor();

    protected:
        /**
         * @brief 材料ID
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-06
         */
        int _materialID{ -1 };
        /**
         * @brief 属性描述
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-06
         */
        QString _describe{};
        /**
         * @brief 颜色
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-06
         */
        float _color[3] = { 0.5, 1.0, 0.0 };
    };

    /**
     * @brief 物理属性管理器
     * @author LiBaojun (libaojunqd@foxmail.com)
     * @date 2024-10-06
     */
    class FITKAcousticsPhysicsAPI FITKAcousticsPhysicsPropManager : public Core::FITKAbstractDataObject
            , public Core::FITKAbstractDataManager<FITKAcousticsAbsPhysicsProp>
    {
        FITKCLASS(Acoustics,FITKAcousticsPhysicsPropManager);
    public:

        /**
         * @brief Construct a new FITKAcousticsPhysicsPropManager object
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-06
         */
        explicit FITKAcousticsPhysicsPropManager() = default;
        /**
         * @brief Destroy the FITKAcousticsPhysicsPropManager object
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-06
         */
        virtual ~FITKAcousticsPhysicsPropManager() = default;

        /**
         * @brief 根据类型获取物理属性对象列表
         * @param[i]  t         物理属性类型
         * @return QList<FITKAcousticsAbsPhysicsProp*> 
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-08
         */
        QList<FITKAcousticsAbsPhysicsProp*> getPhysicsProps(
            FITKAcousticsAbsPhysicsProp::AcousticsPhyscisPropType t);
         
    };



}


#endif
